package com.example.tossednfound;

import java.util.ArrayList;

import android.test.ActivityInstrumentationTestCase2;

public class DavidJUnit extends ActivityInstrumentationTestCase2<LoginActivity> {
	
	public DavidJUnit() {
		super(LoginActivity.class); //class u r using
	}

	protected void setUp() throws Exception {
		super.setUp();
	}

	//test methods must start w/ "test"
	public void testCheckCredentials(){
		RegUser newUser0 = new RegUser("Test0@test.com", "test0", "323 Test0 Way", "AL", 2434, "US", "Test0");
		RegUser newUser1 = new RegUser("Test1@test.com", "test1", "323 Test1 Way", "AL", 2434, "US", "Test1");
		RegUser newUser2 = new RegUser("Test3@test.com", "test3", "323 Test3 Way", "AL", 2434, "US", "Test3");
		newUser2.loginCount = 3;
		ArrayList<RegUser> dummyUserList = new ArrayList<RegUser>();
		dummyUserList.add(newUser0);
		dummyUserList.add(newUser1);
		dummyUserList.add(newUser2);
		LoginActivity.UserList = dummyUserList;
		boolean result0 = false;
		boolean result1 = true;
		boolean result2 = true;
		for(User u: dummyUserList) {
			if(u.checkCredentials(newUser0.email, newUser0.password))
				result0 = true;
			if(!(u.checkCredentials(newUser1.email, "incorrect")))
				result1 = false;
			if(!(u.checkCredentials(newUser2.email, newUser2.password)))
				result2 = false;
		}
		assertTrue(result0);
		assertFalse(result1);
		assertFalse(result2);
	}
}
